@include('admin::layouts.header')
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>商品评论（{{$name}}）</legend>
    </fieldset>
	<div class="demoTable layui-row">
		<div class="layui-form layui-form-pane" style="float:left;width:460px">
			<div class="layui-form-item">
				<label class="layui-form-label">评论时间</label>
				<div style="width:72%" class="layui-input-inline layui-form">
					<input style="width:100%" type="text" class="layui-input" id="created_at" placeholder="请选择时间">
				</div>
			</div>	
		</div>
    </div>
	<div class="demoTable layui-row">
		<button class="layui-btn" style="margin-left:30px;margin-top:15px;" id="search" data-type="reload">查询</button>
		<a href="{{route('shop_admin.product.comments_index',['id'=>$id])}}" style="margin-top:15px;" class="layui-btn">重置</a>
		<a href="{{route('shop_admin.product.index')}}" style="margin-top:15px;" class="layui-btn">返回</a>
	</div>
    <table class="layui-table" id="list" lay-filter="list"></table>
	<div id="test0"></div>  
</div>
@include('admin::layouts.footer')
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="images">
	 @{{#  layui.each(d.images, function(index, item){ }}
		<a class="example-image-link" href="@{{item.url}}" data-lightbox="example-set" data-title="">
		<img src="@{{item.url}}" style="width:50px;height:100%;"/></a>
	 @{{#  }); }}
</script>
<script type="text/html" id="level">
	<div class="test" data-level="@{{d.level}}" style="margin-top:-10px"></div>
</script>

<script type="text/html" id="topBtn">
   <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="delAll()">批量删除</button>
</script>
<script>
    layui.use(['table','form','rate'], function() {
        var table = layui.table,form = layui.form,rate = layui.rate,$ = layui.jquery;
        var tableIn = table.render({
			id: 'ad',
            elem: '#list',
            url: "{{route('shop_admin.product.comments_data',['id'=>$id])}}",
            method:'get',
			toolbar: '#topBtn',
			title:'商品评论（{{$name}}）',
			page: true,
            cols: [[
				{checkbox: true, fixed: true}
                ,{field:'id', title: '编号', width:100,align: 'center',fixed: true,sort: true}
                ,{field:'nick_name', title: '评论人',align: 'center', width:200}
                ,{field:'phone', title: '手机号',align: 'center', width:200}
                ,{field:'content', title: '评论内容',align: 'center', width:300}
                ,{field:'images', title: '图片',align: 'center', width:300, toolbar: '#images'}
                ,{field:'level', title: '评分',align: 'center', width:200, toolbar: '#level'}
                ,{field:'created_at', title: '评论时间',align: 'center', width:200,sort: true}
                ,{width:100, title: '操作',align:'center',align: 'center', toolbar: '#barDemo'} 
            ]],
			limit: "{!! config('admin.common_limit') !!}"
			,done:function(){
				layui.each($('.test'),function(index,elem){
					rate.render({
						elem: elem
						,value: $(elem).attr('data-level')
						,readonly: true
					});
				});
			}
        });
		//搜索
        $('#search').on('click', function () {
			var created_at 		= $('#created_at').val();
            if ($.trim(created_at) === ''){
                layer.msg("{!! config('admin.query_condition') !!}", {icon: 0});
                return;
            }
			tableIn.reload({
				where: {created_at:created_at}
			});
        });
		
    });
</script>
@include('admin::layouts.delete_ajax',['url'=>route('shop_admin.product.comments_destroy',['product_id'=>$id])])
@include('admin::layouts.delete_all_ajax',['url'=>route('shop_admin.product.comments_destroy_all',['product_id'=>$id])])
</body>
</html>